package com.hw.common.enums;

/**
 * 性别状态枚举
 */
public enum GenderStatusEnum {
    MAN(1, "man"),
    WOMAN(2, "woman"),
    UNKNOW(3, "unknow");

    private Integer code;
    private String name;

    GenderStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据code返回枚举对象
     *
     * @param code
     * @return
     */
    public static GenderStatusEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (GenderStatusEnum commandEnum : GenderStatusEnum.values()) {
            if (commandEnum.getCode().intValue() == code.intValue()) {
                return commandEnum;
            }
        }
        return GenderStatusEnum.UNKNOW;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
